const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    eIndex: 0
  },

  // 菜单切换类名on
  tab: function (e) {
    this.setData({
      eIndex: e.currentTarget.dataset.index
    })
       this.loadGifts()
  },

  // 跳转到我的收到
  toOpenGift: function (e) {
    let id = e.currentTarget.dataset.value.id
    let orderId = e.currentTarget.dataset.value.orderId
    wx.navigateTo({
      url: '../open-gift/open-gift?giftId='+id+'&orderId='+orderId
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
       this.loadGifts()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },
     loadGifts: function () {
          let that = this
          var data = { 'memberId': app.globalData.userInfo.id, 'searchType': 2, 'status': that.data.eIndex }
          var promise = app.synPostData('gift/select', data)
          promise.then(function (res) {
               that.setData({
                    gifts: res.data.result
               })
          })
     }
  

})